<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminPermissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin_permissions', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique(); // 权限名称
            $table->string('display_name'); // 显示名称
            $table->string('description')->nullable(); // 权限描述
            $table->string('module'); // 所属模块
            $table->enum('type', ['menu', 'action', 'impersonation']); // 权限类型
            $table->timestamps();
            
            // 索引
            $table->index(['module', 'type']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_permissions');
    }
}